package com.baomidou.ant.service.impl;

import com.baomidou.ant.entity.ApplyInternshipInfo;
import com.baomidou.ant.entity.ApplyTrainInfo;
import com.baomidou.ant.mapper.ApplyTrainInfoMapper;
import com.baomidou.ant.service.IApplyTrainInfoService;
import com.baomidou.ant.vo.request.RequestInternshipInfoVo;
import com.baomidou.ant.vo.request.RequestTrainInfoVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jobob
 * @since 2022-09-20
 */
@Service
public class ApplyTrainInfoServiceImpl extends ServiceImpl<ApplyTrainInfoMapper, ApplyTrainInfo> implements IApplyTrainInfoService {

    @Override
    public List<RequestTrainInfoVo> queryByAId(Integer aid) {
        List<RequestTrainInfoVo> voList=new ArrayList<>();
        QueryWrapper<ApplyTrainInfo> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("apply_info_id",aid);
        List<ApplyTrainInfo> applyTrainInfoList=list(queryWrapper);
        for(ApplyTrainInfo applyTrainInfo:applyTrainInfoList){
            RequestTrainInfoVo vo=new RequestTrainInfoVo();
            BeanUtils.copyProperties(applyTrainInfo,vo);
            if(Objects.equals(applyTrainInfo.getObtainCertificate(), "1")){
                vo.setObtainCertificate("是");
            }else
                vo.setObtainCertificate("否");
            voList.add(vo);
        }
        return voList;
    }
}
